/**
 * 
 */
package sailing.filters;

import java.awt.Component;

import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextField;

import sailing.filters.ui.laf.FilterTextFieldUI;
import sailing.listener.UI;
import sailing.ui.base.DateChooser;

import com.jgoodies.forms.layout.CellConstraints;
import com.jgoodies.forms.layout.FormLayout;

/**
 * @author kevin
 * 
 */
public class DurationFilter extends Filter {

	private static final String filterName = "时间期限检索条件";

	private JTextField startTF, endTF;
	private static FormLayout playout = new FormLayout("c:14dlu,f:50dlu,c:14dlu,f:50dlu", "16dlu");

	private DateChooser dcFrom = DateChooser.getInstance("yyyy-MM-dd");
	private DateChooser dcTo = DateChooser.getInstance("yyyy-MM-dd");

	public DurationFilter() {
		super(filterName);
	}

	@Override
	protected Component getInternalCellPanel() {
		JPanel panel = new JPanel();
		panel.setFont(UI.font12);
		panel.setLayout(playout);

		CellConstraints cc = new CellConstraints();

		JLabel from = new JLabel("从");
		from.setFont(UI.font12);
		panel.add(from, cc.xy(1, 1));
		startTF = new JTextField();
		startTF.setEditable(false);
		startTF.setFont(UI.font12);
		startTF.setUI(new FilterTextFieldUI());
		dcFrom.register(startTF);
		panel.add(startTF, cc.xy(2, 1));

		JLabel to = new JLabel("到");
		to.setFont(UI.font12);
		panel.add(to, cc.xy(3, 1));
		endTF = new JTextField();
		endTF.setFont(UI.font12);
		endTF.setEditable(false);
		endTF.setUI(new FilterTextFieldUI());
		dcTo.register(endTF);
		panel.add(endTF, cc.xy(4, 1));

		return panel;
	}

}
